package com.zbf.threadLocal;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/17  10:10
 * 描述:
 */
public class MyThread1 extends Thread {

    private ThreadLocal<User11> threadLocal;

    public MyThread1(ThreadLocal threadLocal) {
        this.threadLocal = threadLocal;
    }

    @Override
    public void run() {
        User11 user11 = new User11();
        user11.setUserName("11111111111");
        threadLocal.set(user11);
        try {
            test11();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public void test11( ) throws InterruptedException {
        User11 user11 = threadLocal.get();
        Thread.sleep(5000);
        System.out.println(user11.getUserName());
    }
}
